Skip to content

Test that tag keys are held to the same limits as names and values - #35

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/test-tag-field-limits
Nov 18, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/test-tag-field-limits

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B unit-test expansion: the "Fits the server's limits" row of the README's report promise table is now covered field by field. Production code is not changed.

  • tagKeysAreCutAndCleanedLikeNamesAndValues (new): a tag key is cut to 255 bytes and is never cut in the middle of a character, and invalid UTF-8 in a key or a value becomes U+FFFD. Before this PR, only names and values were tested for the 255-byte cut, and only names were tested for U+FFFD.
  • blankTagKeysDoNotCountTowardTheTagCap (new): blank keys ("", "\t", " ") sort before the real keys but are dropped without using up the 32-tag cap, so all 32 real tags are still sent.
  • jsonIsEscapedAndCleaned: adds one assertion that a negative infinite value is left out, alongside the existing NaN and +inf assertions.

No tracking issue. The gap was found during triage.

Skipped issues

A documentation sweep was also run against trace_client.hpp, Makefile, CMakeLists.txt and .github/workflows/build.yml. It found no drift beyond what #1 and #21 already track (for #21, the README says tags "always holds at least version").

Test plan

  • make test (g++, C++11, -Werror): 79 tests, 0 failed checks (up from 77, because two tests were added and both are registered in tests[])
  • Mutation check: changing the header to clean tag keys with no length limit, and to count blank keys toward the cap, makes both new tests fail, along with the existing blank-key check in jsonIsEscapedAndCleaned (79 tests, 5 failed checks). After the header was restored, the suite is green again.
  • CI Build green on all jobs

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

The README promises names and tag keys/values are cut to 255 bytes, invalid
UTF-8 becomes U+FFFD, blank keys are dropped and at most 32 tags are sent.
Only names and values had a test for the cut, and nothing showed that a
dropped blank key leaves its slot under the cap to a real tag. Also check
that a negative infinite value is left out, as NaN and +inf already are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (head 77330e9):

  • Scope: PASS. Only test/test_trace_client.cpp changed (+33 lines). There is no production, formatting or rename churn.
  • Tests-new: PASS. No public method or function was added. The PR only adds tests.
  • Tests-fix: N/A. This is not a bug fix. As a sensitivity check, the header was changed to clean tag keys with no length limit and to count blank keys toward the cap. Both new tests failed (79 tests, 5 failed checks). After trace_client.hpp was restored, the suite printed 79 tests, 0 failed checks.
  • Sibling structure: PASS. The new tests follow the neighbouring tagsAreHeldToTheServerLimits style: static void sentence names, using trace_client::detail::json, and CHECK / CHECK_EQ.
  • Sibling renames: N/A. Nothing was renamed.
  • Docs: PASS. The tests assert the existing README "Fits the server's limits" row, so no doc change is needed.
  • Issue resolution: N/A. There is no Closes, because the gap was found during triage.
  • CI: PASS. All 11 Build jobs are green on 77330e9, including both sanitizer jobs, macOS and Windows/MSVC.
  • Registered: PASS. tagKeysAreCutAndCleanedLikeNamesAndValues and blankTagKeysDoNotCountTowardTheTagCap each appear twice (once as the definition and once in tests[]), and the test count rose from 77 to 79.
  • C++11: PASS. make test (g++, -std=c++11 -Werror) built with no warnings, and the CI c++11 legs are green.
  • No new dependency / Never throws / Curl argv fixed / Version triple: N/A. trace_client.hpp, Makefile and CMakeLists.txt are untouched.
  • Sanitizers: PASS. The thread and address,undefined jobs are green.

Judgment note: test/test_trace_client.cpp:875: blankTagKeysDoNotCountTowardTheTagCap relies on std::map ordering to put the blank keys before k100…k131. That ordering is guaranteed, because "", "\t" and " " all sort below "k". The test comment states the dependency.

Out-of-diff observation: detail::json cleans application with no byte limit (cleanUtf8(application, std::string::npos)). Unlike a name or a tag field, an overlong application name is sent in full. The README's limits row lists only names and tag keys/values, so this is not doc drift, and it was left uncharacterized here.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit a437813 into main Nov 18, 2026
11 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/test-tag-field-limits branch November 18, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant